package com.legna.mhxy.support.controller;

import com.legna.mhxy.support.service.StockService;
import com.legna.mhxy.support.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


@Tag(name="分析")
@RestController
@RequestMapping("/stock")
@AllArgsConstructor
public class StockController {

    private final StockService stockService;

    @PutMapping("/increase/{userRingId}")
    @Operation(summary = "分析 数量少的环")
    public Result<String> increase(@PathVariable("userRingId")Long userRingId,
                                                 @RequestParam(value = "count",required = false,defaultValue = "1") Integer count) {
        stockService.increase(userRingId,count);
        return Result.ok();
    }

    @PutMapping("/decrease/{userRingId}")
    @Operation(summary = "分析 数量少的环")
    public Result<String> decrease(@PathVariable("userRingId")Long userRingId,
                                   @RequestParam(value = "count",required = false,defaultValue = "1") Integer count,
                                   @RequestParam(value = "taskId") Long taskId) {
        stockService.decrease(userRingId,count,taskId);
        return Result.ok();
    }

    @PutMapping("/increase")
    @Operation(summary = "分析 数量少的环")
    public Result<String> increaseByUserType(@RequestParam(value = "userId") Long userId,@RequestParam(value = "typeId") Long typeId,
                                                 @RequestParam(value = "count",required = false,defaultValue = "1") Integer count) {
        stockService.increaseByUserType(userId,typeId,count);
        return Result.ok();
    }

    @PutMapping("/decrease")
    @Operation(summary = "分析 数量少的环")
    public Result<String> decreaseByUserType(@RequestParam(value = "userId") Long userId,@RequestParam(value = "typeId") Long typeId,
                                                 @RequestParam(value = "count",required = false,defaultValue = "1") Integer count,
                                             @RequestParam(value = "taskId") Long taskId) {
        stockService.decreaseByUserType(userId,typeId,count,taskId);
        return Result.ok();
    }
}
